namespace pos.entity
{
using System;
using System.Data;
using System.Configuration;
using System.Text;
using System.Data.OleDb;
using System.Collections;
using System.Windows.Forms;
using NHibernate;
using NHibernate.Criterion;
/// <summary>
/// t_commodity 的摘要说明
/// </summary>
public class t_commodity:IEntityUtil
{
//   商品状态值的哈希表 
	private static Hashtable m_enum_commodityState;
	public static Hashtable  enum_commodityState
	{
		get{return m_enum_commodityState;}
	}
	public const int NORMAL=101;
	public const int STOP=100;
//   库存状态值的哈希表 
	private static Hashtable m_enum_storageState;
	public static Hashtable  enum_storageState
	{
		get{return m_enum_storageState;}
	}
	public const int STORAGEYES=111;
	public const int STORAGENO=110;
//   是否特价值的哈希表 
	private static Hashtable m_enum_specialOffer;
	public static Hashtable  enum_specialOffer
	{
		get{return m_enum_specialOffer;}
	}
	public const int SPECIALYES=11;
	public const int SPECIALNO=10;
//   是否包装值的哈希表 
	private static Hashtable m_enum_packageFlag;
	public static Hashtable  enum_packageFlag
	{
		get{return m_enum_packageFlag;}
	}
	public const int YESPACKAGE=0;
	public const int NOPACKAGE=1;
	//   列名称哈希表 
	private static Hashtable m_colLabels;    	 
	public static Hashtable colLabels//
	{
		get{return m_colLabels;}
	}
	//表字段名称哈希表
	private static ArrayList m_colNames;     
	public static ArrayList  colNames　
	{
		get{return m_colNames;}
	}
	private Commodity __commodity;
	public long seqID  
	{
		get{return __commodity.seqID;}
		set{ __commodity.seqID=value;}
	}
	public String commodityID  
	{
		get{return __commodity.commodityID;}
		set{ __commodity.commodityID=value;}
	}
	public String commodityName  
	{
		get{return __commodity.commodityName;}
		set{ __commodity.commodityName=value;}
	}
	public String commoditySpec  
	{
		get{return __commodity.commoditySpec;}
		set{ __commodity.commoditySpec=value;}
	}
	public int commodityState  
	{
		get{return __commodity.commodityState;}
		set{ __commodity.commodityState=value;}
	}
	public int storageState  
	{
		get{return __commodity.storageState;}
		set{ __commodity.storageState=value;}
	}
	public double retailPrice  
	{
		get{return __commodity.retailPrice;}
		set{ __commodity.retailPrice=value;}
	}
	public int specialOffer  
	{
		get{return __commodity.specialOffer;}
		set{ __commodity.specialOffer=value;}
	}
	public double specialPrice  
	{
		get{return __commodity.specialPrice;}
		set{ __commodity.specialPrice=value;}
	}
	public double wholesalePrice  
	{
		get{return __commodity.wholesalePrice;}
		set{ __commodity.wholesalePrice=value;}
	}
	public double memberPrice1  
	{
		get{return __commodity.memberPrice1;}
		set{ __commodity.memberPrice1=value;}
	}
	public double memberPrice2  
	{
		get{return __commodity.memberPrice2;}
		set{ __commodity.memberPrice2=value;}
	}
	public double memberPrice3  
	{
		get{return __commodity.memberPrice3;}
		set{ __commodity.memberPrice3=value;}
	}
	public int packageFlag  
	{
		get{return __commodity.packageFlag;}
		set{ __commodity.packageFlag=value;}
	}
	public String packageCommodityID  
	{
		get{return __commodity.packageCommodityID;}
		set{ __commodity.packageCommodityID=value;}
	}
	public double packageAmount  
	{
		get{return __commodity.packageAmount;}
		set{ __commodity.packageAmount=value;}
	}
	public String commodityClass1  
	{
		get{return __commodity.commodityClass1;}
		set{ __commodity.commodityClass1=value;}
	}
	public String commodityClass2  
	{
		get{return __commodity.commodityClass2;}
		set{ __commodity.commodityClass2=value;}
	}
	public String commodityClass3  
	{
		get{return __commodity.commodityClass3;}
		set{ __commodity.commodityClass3=value;}
	}
	public String pos1  
	{
		get{return __commodity.pos1;}
		set{ __commodity.pos1=value;}
	}
	public String pos2  
	{
		get{return __commodity.pos2;}
		set{ __commodity.pos2=value;}
	}
	public String commodityBrank  
	{
		get{return __commodity.commodityBrank;}
		set{ __commodity.commodityBrank=value;}
	}
	public String commodityFactory  
	{
		get{return __commodity.commodityFactory;}
		set{ __commodity.commodityFactory=value;}
	}
	public String grade  
	{
		get{return __commodity.grade;}
		set{ __commodity.grade=value;}
	}
	public String unit  
	{
		get{return __commodity.unit;}
		set{ __commodity.unit=value;}
	}
	public String mark  
	{
		get{return __commodity.mark;}
		set{ __commodity.mark=value;}
	}
	public String commodityType  
	{
		get{return __commodity.commodityType;}
		set{ __commodity.commodityType=value;}
	}
	public String commodityKey  
	{
		get{return __commodity.commodityKey;}
		set{ __commodity.commodityKey=value;}
	}
	public String commodityRemark  
	{
		get{return __commodity.commodityRemark;}
		set{ __commodity.commodityRemark=value;}
	}
	public String addUserID  
	{
		get{return __commodity.addUserID;}
		set{ __commodity.addUserID=value;}
	}
	public DateTime addTime  
	{
		get{return __commodity.addTime;}
		set{ __commodity.addTime=value;}
	}
	public String modifyUserID  
	{
		get{return __commodity.modifyUserID;}
		set{ __commodity.modifyUserID=value;}
	}
	public DateTime modifyTime  
	{
		get{return __commodity.modifyTime;}
		set{ __commodity.modifyTime=value;}
	}
	private static  CommodityDao dao=(CommodityDao)SpringContext.Context.GetObject("CommodityDao");
	public static CommodityDao DAO
	{
		get{return dao;}
		
	}
	
	public t_commodity()
	{
		__commodity=new Commodity();
	  	seqID=consts.long_min;
	  	commodityID="";
	  	commodityName="";
	  	commoditySpec="";
	  	commodityState=consts.int_min;
	  	storageState=consts.int_min;
	  	retailPrice=consts.double_min;
	  	specialOffer=consts.int_min;
	  	specialPrice=consts.double_min;
	  	wholesalePrice=consts.double_min;
	  	memberPrice1=consts.double_min;
	  	memberPrice2=consts.double_min;
	  	memberPrice3=consts.double_min;
	  	packageFlag=consts.int_min;
	  	packageCommodityID="";
	  	packageAmount=consts.double_min;
	  	commodityClass1="";
	  	commodityClass2="";
	  	commodityClass3="";
	  	pos1="";
	  	pos2="";
	  	commodityBrank="";
	  	commodityFactory="";
	  	grade="";
	  	unit="";
	  	mark="";
	  	commodityType="";
	  	commodityKey="";
	  	commodityRemark="";
	  	addUserID="";
	  	addTime=DateTime.Now;
	  	modifyUserID="";
	  	modifyTime=DateTime.Now;
	  // dao=(CommodityDao)SpringContext.Context.GetObject("CommodityDao");
	   if(m_colLabels==null)
	   {
		m_colLabels = new Hashtable();
        m_colNames= new ArrayList();
		m_colLabels.Add("seqID", @"编号");
		colNames.Add("seqID");
		m_colLabels.Add("commodityID", @"商品条形码");
		colNames.Add("commodityID");
		m_colLabels.Add("commodityName", @"商品名称");
		colNames.Add("commodityName");
		m_colLabels.Add("commoditySpec", @"规格");
		colNames.Add("commoditySpec");
		m_colLabels.Add("commodityState", @"商品状态");
		colNames.Add("commodityState");
		m_enum_commodityState= new Hashtable();
		m_enum_commodityState.Add("101", @"正常");
		m_enum_commodityState.Add("100", @"停用");
		m_colLabels.Add("storageState", @"库存状态");
		colNames.Add("storageState");
		m_enum_storageState= new Hashtable();
		m_enum_storageState.Add("111", @"正常");
		m_enum_storageState.Add("110", @"停用");
		m_colLabels.Add("retailPrice", @"零售价");
		colNames.Add("retailPrice");
		m_colLabels.Add("specialOffer", @"是否特价");
		colNames.Add("specialOffer");
		m_enum_specialOffer= new Hashtable();
		m_enum_specialOffer.Add("11", @"特价");
		m_enum_specialOffer.Add("10", @"普通");
		m_colLabels.Add("specialPrice", @"特价");
		colNames.Add("specialPrice");
		m_colLabels.Add("wholesalePrice", @"批发价");
		colNames.Add("wholesalePrice");
		m_colLabels.Add("memberPrice1", @"会员价1");
		colNames.Add("memberPrice1");
		m_colLabels.Add("memberPrice2", @"会员价2");
		colNames.Add("memberPrice2");
		m_colLabels.Add("memberPrice3", @"会员价3");
		colNames.Add("memberPrice3");
		m_colLabels.Add("packageFlag", @"是否包装");
		colNames.Add("packageFlag");
		m_enum_packageFlag= new Hashtable();
		m_enum_packageFlag.Add("0", @"普通商品");
		m_enum_packageFlag.Add("1", @"包装商品");
		m_colLabels.Add("packageCommodityID", @"包装商品号");
		colNames.Add("packageCommodityID");
		m_colLabels.Add("packageAmount", @"包装数");
		colNames.Add("packageAmount");
		m_colLabels.Add("commodityClass1", @"大类");
		colNames.Add("commodityClass1");
		m_colLabels.Add("commodityClass2", @"中类");
		colNames.Add("commodityClass2");
		m_colLabels.Add("commodityClass3", @"小类");
		colNames.Add("commodityClass3");
		m_colLabels.Add("pos1", @"货架位置");
		colNames.Add("pos1");
		m_colLabels.Add("pos2", @"仓库位置");
		colNames.Add("pos2");
		m_colLabels.Add("commodityBrank", @"品牌");
		colNames.Add("commodityBrank");
		m_colLabels.Add("commodityFactory", @"厂家(产地)");
		colNames.Add("commodityFactory");
		m_colLabels.Add("grade", @"等级");
		colNames.Add("grade");
		m_colLabels.Add("unit", @"单位");
		colNames.Add("unit");
		m_colLabels.Add("mark", @"货号");
		colNames.Add("mark");
		m_colLabels.Add("commodityType", @"型号");
		colNames.Add("commodityType");
		m_colLabels.Add("commodityKey", @"索引");
		colNames.Add("commodityKey");
		m_colLabels.Add("commodityRemark", @"备注");
		colNames.Add("commodityRemark");
		m_colLabels.Add("addUserID", @"添加人");
		colNames.Add("addUserID");
		m_colLabels.Add("addTime", @"添加时间");
		colNames.Add("addTime");
		m_colLabels.Add("modifyUserID", @"修改人");
		colNames.Add("modifyUserID");
		m_colLabels.Add("modifyTime", @"修改时间");
		colNames.Add("modifyTime");
	  }
	
	}
	public t_commodity(Commodity entity )
	{
		__commodity=entity;
		
	  // dao=(CommodityDao)SpringContext.Context.GetObject("CommodityDao");
	   if(m_colLabels==null)
	   {
		m_colLabels = new Hashtable();
        m_colNames= new ArrayList();
		m_colLabels.Add("seqID", @"编号");
		colNames.Add("seqID");
		m_colLabels.Add("commodityID", @"商品条形码");
		colNames.Add("commodityID");
		m_colLabels.Add("commodityName", @"商品名称");
		colNames.Add("commodityName");
		m_colLabels.Add("commoditySpec", @"规格");
		colNames.Add("commoditySpec");
		m_colLabels.Add("commodityState", @"商品状态");
		colNames.Add("commodityState");
		m_enum_commodityState= new Hashtable();
		m_enum_commodityState.Add("101", @"正常");
		m_enum_commodityState.Add("100", @"停用");
		m_colLabels.Add("storageState", @"库存状态");
		colNames.Add("storageState");
		m_enum_storageState= new Hashtable();
		m_enum_storageState.Add("111", @"正常");
		m_enum_storageState.Add("110", @"停用");
		m_colLabels.Add("retailPrice", @"零售价");
		colNames.Add("retailPrice");
		m_colLabels.Add("specialOffer", @"是否特价");
		colNames.Add("specialOffer");
		m_enum_specialOffer= new Hashtable();
		m_enum_specialOffer.Add("11", @"特价");
		m_enum_specialOffer.Add("10", @"普通");
		m_colLabels.Add("specialPrice", @"特价");
		colNames.Add("specialPrice");
		m_colLabels.Add("wholesalePrice", @"批发价");
		colNames.Add("wholesalePrice");
		m_colLabels.Add("memberPrice1", @"会员价1");
		colNames.Add("memberPrice1");
		m_colLabels.Add("memberPrice2", @"会员价2");
		colNames.Add("memberPrice2");
		m_colLabels.Add("memberPrice3", @"会员价3");
		colNames.Add("memberPrice3");
		m_colLabels.Add("packageFlag", @"是否包装");
		colNames.Add("packageFlag");
		m_enum_packageFlag= new Hashtable();
		m_enum_packageFlag.Add("0", @"普通商品");
		m_enum_packageFlag.Add("1", @"包装商品");
		m_colLabels.Add("packageCommodityID", @"包装商品号");
		colNames.Add("packageCommodityID");
		m_colLabels.Add("packageAmount", @"包装数");
		colNames.Add("packageAmount");
		m_colLabels.Add("commodityClass1", @"大类");
		colNames.Add("commodityClass1");
		m_colLabels.Add("commodityClass2", @"中类");
		colNames.Add("commodityClass2");
		m_colLabels.Add("commodityClass3", @"小类");
		colNames.Add("commodityClass3");
		m_colLabels.Add("pos1", @"货架位置");
		colNames.Add("pos1");
		m_colLabels.Add("pos2", @"仓库位置");
		colNames.Add("pos2");
		m_colLabels.Add("commodityBrank", @"品牌");
		colNames.Add("commodityBrank");
		m_colLabels.Add("commodityFactory", @"厂家(产地)");
		colNames.Add("commodityFactory");
		m_colLabels.Add("grade", @"等级");
		colNames.Add("grade");
		m_colLabels.Add("unit", @"单位");
		colNames.Add("unit");
		m_colLabels.Add("mark", @"货号");
		colNames.Add("mark");
		m_colLabels.Add("commodityType", @"型号");
		colNames.Add("commodityType");
		m_colLabels.Add("commodityKey", @"索引");
		colNames.Add("commodityKey");
		m_colLabels.Add("commodityRemark", @"备注");
		colNames.Add("commodityRemark");
		m_colLabels.Add("addUserID", @"添加人");
		colNames.Add("addUserID");
		m_colLabels.Add("addTime", @"添加时间");
		colNames.Add("addTime");
		m_colLabels.Add("modifyUserID", @"修改人");
		colNames.Add("modifyUserID");
		m_colLabels.Add("modifyTime", @"修改时间");
		colNames.Add("modifyTime");
	  }
	
	}
	public Object uniqueResult(DetachedCriteria dc)
    {
        return dao.uniqueResult(dc);
    }
	 public DetachedCriteria DC 
     {
        	get{return DetachedCriteria.For(typeof(Commodity));}
     }
	public const string ENTITYNAME="t_commodity";
	public const int SEQN0=100;
	
    public void checkAdd()
    {
		int len;
	//try{Convert.ToInt64(seqID);}catch{ throw (new Exception("请输入正确的长整数格式"));		}
		if(	seqID<consts.long_min+1)
			throw (new Exception("请输入编号"));
 if(				(				  string.Format("{0}",seqID)				  )=="0")
	 throw (new Exception("编号是主健，框架要求值不能为0"));				

	
	len=commodityID.Trim().Length;
	if(len>50)
		 throw (new Exception("商品条形码字符长度最长不能超过50,当前长度为"+len.ToString()));	
	else if(len==0)
		throw (new Exception("商品条形码不能为空!"));	
	

	
	len=commodityName.Trim().Length;
	if(len>50)
		 throw (new Exception("商品名称字符长度最长不能超过50,当前长度为"+len.ToString()));	
	else if(len==0)
		throw (new Exception("商品名称不能为空!"));	
	

	
	len=commoditySpec.Trim().Length;
	if(len>20)
		 throw (new Exception("规格字符长度最长不能超过20,当前长度为"+len.ToString()));	
	

	//try{Convert.ToInt32(commodityState);}catch{ throw (new Exception("请输入正确的整数格式"));		}
		if(	commodityState<consts.int_min+1)
			throw (new Exception("请输入商品状态"));

	//try{Convert.ToInt32(storageState);}catch{ throw (new Exception("请输入正确的整数格式"));		}
		if(	storageState<consts.int_min+1)
			throw (new Exception("请输入库存状态"));

	//try{Convert.ToDouble(retailPrice);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	retailPrice<consts.double_min+1)
			throw (new Exception("请输入零售价"));
		if(retailPrice>0)
			retailPrice+=0.000001;
		if(retailPrice<0)
			retailPrice-=0.000001;
		
			if(((long)((retailPrice)*100 ))*10!=(long)((retailPrice)*1000) )
				throw (new Exception("零售价小数精度不能大于2位retailPrice="+retailPrice.ToString()));
		if(retailPrice>0)
			retailPrice-=0.000001;
		if(retailPrice<0)
			retailPrice+=0.000001;
	

	//try{Convert.ToInt32(specialOffer);}catch{ throw (new Exception("请输入正确的整数格式"));		}
		if(	specialOffer<consts.int_min+1)
			throw (new Exception("请输入是否特价"));

	//try{Convert.ToDouble(specialPrice);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(specialPrice>0)
			specialPrice+=0.000001;
		if(specialPrice<0)
			specialPrice-=0.000001;
		
			if(((long)((specialPrice)*100 ))*10!=(long)((specialPrice)*1000) )
				throw (new Exception("特价小数精度不能大于2位specialPrice="+specialPrice.ToString()));
		if(specialPrice>0)
			specialPrice-=0.000001;
		if(specialPrice<0)
			specialPrice+=0.000001;
	

	//try{Convert.ToDouble(wholesalePrice);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(wholesalePrice>0)
			wholesalePrice+=0.000001;
		if(wholesalePrice<0)
			wholesalePrice-=0.000001;
		
			if(((long)((wholesalePrice)*100 ))*10!=(long)((wholesalePrice)*1000) )
				throw (new Exception("批发价小数精度不能大于2位wholesalePrice="+wholesalePrice.ToString()));
		if(wholesalePrice>0)
			wholesalePrice-=0.000001;
		if(wholesalePrice<0)
			wholesalePrice+=0.000001;
	

	//try{Convert.ToDouble(memberPrice1);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(memberPrice1>0)
			memberPrice1+=0.000001;
		if(memberPrice1<0)
			memberPrice1-=0.000001;
		
			if(((long)((memberPrice1)*100 ))*10!=(long)((memberPrice1)*1000) )
				throw (new Exception("会员价1小数精度不能大于2位memberPrice1="+memberPrice1.ToString()));
		if(memberPrice1>0)
			memberPrice1-=0.000001;
		if(memberPrice1<0)
			memberPrice1+=0.000001;
	

	//try{Convert.ToDouble(memberPrice2);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(memberPrice2>0)
			memberPrice2+=0.000001;
		if(memberPrice2<0)
			memberPrice2-=0.000001;
		
			if(((long)((memberPrice2)*100 ))*10!=(long)((memberPrice2)*1000) )
				throw (new Exception("会员价2小数精度不能大于2位memberPrice2="+memberPrice2.ToString()));
		if(memberPrice2>0)
			memberPrice2-=0.000001;
		if(memberPrice2<0)
			memberPrice2+=0.000001;
	

	//try{Convert.ToDouble(memberPrice3);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(memberPrice3>0)
			memberPrice3+=0.000001;
		if(memberPrice3<0)
			memberPrice3-=0.000001;
		
			if(((long)((memberPrice3)*100 ))*10!=(long)((memberPrice3)*1000) )
				throw (new Exception("会员价3小数精度不能大于2位memberPrice3="+memberPrice3.ToString()));
		if(memberPrice3>0)
			memberPrice3-=0.000001;
		if(memberPrice3<0)
			memberPrice3+=0.000001;
	

	//try{Convert.ToInt32(packageFlag);}catch{ throw (new Exception("请输入正确的整数格式"));		}
		if(	packageFlag<consts.int_min+1)
			throw (new Exception("请输入是否包装"));

	
	len=packageCommodityID.Trim().Length;
	if(len>50)
		 throw (new Exception("包装商品号字符长度最长不能超过50,当前长度为"+len.ToString()));	
	

	//try{Convert.ToDouble(packageAmount);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(packageAmount>0)
			packageAmount+=0.000001;
		if(packageAmount<0)
			packageAmount-=0.000001;
		
			if(((long)((packageAmount)*100 ))*10!=(long)((packageAmount)*1000) )
				throw (new Exception("包装数小数精度不能大于2位packageAmount="+packageAmount.ToString()));
		if(packageAmount>0)
			packageAmount-=0.000001;
		if(packageAmount<0)
			packageAmount+=0.000001;
	

	
	len=commodityClass1.Trim().Length;
	if(len>20)
		 throw (new Exception("大类字符长度最长不能超过20,当前长度为"+len.ToString()));	
	

	
	len=commodityClass2.Trim().Length;
	if(len>20)
		 throw (new Exception("中类字符长度最长不能超过20,当前长度为"+len.ToString()));	
	

	
	len=commodityClass3.Trim().Length;
	if(len>20)
		 throw (new Exception("小类字符长度最长不能超过20,当前长度为"+len.ToString()));	
	

	
	len=pos1.Trim().Length;
	if(len>20)
		 throw (new Exception("货架位置字符长度最长不能超过20,当前长度为"+len.ToString()));	
	

	
	len=pos2.Trim().Length;
	if(len>20)
		 throw (new Exception("仓库位置字符长度最长不能超过20,当前长度为"+len.ToString()));	
	

	
	len=commodityBrank.Trim().Length;
	if(len>20)
		 throw (new Exception("品牌字符长度最长不能超过20,当前长度为"+len.ToString()));	
	

	
	len=commodityFactory.Trim().Length;
	if(len>20)
		 throw (new Exception("厂家(产地)字符长度最长不能超过20,当前长度为"+len.ToString()));	
	

	
	len=grade.Trim().Length;
	if(len>20)
		 throw (new Exception("等级字符长度最长不能超过20,当前长度为"+len.ToString()));	
	

	
	len=unit.Trim().Length;
	if(len>20)
		 throw (new Exception("单位字符长度最长不能超过20,当前长度为"+len.ToString()));	
	

	
	len=mark.Trim().Length;
	if(len>20)
		 throw (new Exception("货号字符长度最长不能超过20,当前长度为"+len.ToString()));	
	

	
	len=commodityType.Trim().Length;
	if(len>20)
		 throw (new Exception("型号字符长度最长不能超过20,当前长度为"+len.ToString()));	
	

	
	len=commodityKey.Trim().Length;
	if(len>50)
		 throw (new Exception("索引字符长度最长不能超过50,当前长度为"+len.ToString()));	
	

	
	len=commodityRemark.Trim().Length;
	if(len>512)
		 throw (new Exception("备注字符长度最长不能超过512,当前长度为"+len.ToString()));	
	

	
	len=addUserID.Trim().Length;
	if(len>20)
		 throw (new Exception("添加人字符长度最长不能超过20,当前长度为"+len.ToString()));	
	

	//try{Convert.ToDateTime(addTime);}catch{ throw (new Exception("请输入正确的长整数格式"));		}

	
	len=modifyUserID.Trim().Length;
	if(len>20)
		 throw (new Exception("修改人字符长度最长不能超过20,当前长度为"+len.ToString()));	
	

	//try{Convert.ToDateTime(modifyTime);}catch{ throw (new Exception("请输入正确的长整数格式"));		}

//unique="yes" 唯一性验证
		ICriterion crit=Restrictions.Eq("commodityID", commodityID);
		crit=Restrictions.Or(crit,Restrictions.Eq("commodityName", commodityName));
  		IList list=dao.List(dao.DC.Add(crit));
		if(list.Count==0)
			return;
		Commodity obj=list[0] as Commodity;
//唯一性异常消息抛出
		if( obj.commodityID==commodityID)
		{
			throw (new Exception(string.Format("商品条形码:{0}已经存在",commodityID)));	
		}
		if( obj.commodityName==commodityName)
		{
			throw (new Exception(string.Format("商品名称:{0}已经存在",commodityName)));	
		}
	//end unique="yes" 唯一性验证
    }
    public void checkUpdate()
    {
		int len;
	//try{Convert.ToInt64(seqID);}catch{ throw (new Exception("请输入正确的长整数格式"));		}
		if(	seqID<consts.long_min+1)
			throw (new Exception("请输入编号"));
 if(				(				  string.Format("{0}",seqID)				  )=="0")
	 throw (new Exception("编号是主健，框架要求值不能为0"));				

	
	len=commodityID.Trim().Length;
	if(len>50)
		 throw (new Exception("商品条形码字符长度最长不能超过50,当前长度为"+len.ToString()));	
	else if(len==0)
		throw (new Exception("商品条形码不能为空!"));	
	

	
	len=commodityName.Trim().Length;
	if(len>50)
		 throw (new Exception("商品名称字符长度最长不能超过50,当前长度为"+len.ToString()));	
	else if(len==0)
		throw (new Exception("商品名称不能为空!"));	
	

	
	len=commoditySpec.Trim().Length;
	if(len>20)
		 throw (new Exception("规格字符长度最长不能超过20,当前长度为"+len.ToString()));	
	

	//try{Convert.ToInt32(commodityState);}catch{ throw (new Exception("请输入正确的整数格式"));		}
		if(	commodityState<consts.int_min+1)
			throw (new Exception("请输入商品状态"));

	//try{Convert.ToInt32(storageState);}catch{ throw (new Exception("请输入正确的整数格式"));		}
		if(	storageState<consts.int_min+1)
			throw (new Exception("请输入库存状态"));

	//try{Convert.ToDouble(retailPrice);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	retailPrice<consts.double_min+1)
			throw (new Exception("请输入零售价"));
		if(retailPrice>0)
			retailPrice+=0.000001;
		if(retailPrice<0)
			retailPrice-=0.000001;
		
			if(((long)((retailPrice)*100 ))*10!=(long)((retailPrice)*1000) )
				throw (new Exception("零售价小数精度不能大于2位retailPrice="+retailPrice.ToString()));
		if(retailPrice>0)
			retailPrice-=0.000001;
		if(retailPrice<0)
			retailPrice+=0.000001;
	

	//try{Convert.ToInt32(specialOffer);}catch{ throw (new Exception("请输入正确的整数格式"));		}
		if(	specialOffer<consts.int_min+1)
			throw (new Exception("请输入是否特价"));

	//try{Convert.ToDouble(specialPrice);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(specialPrice>0)
			specialPrice+=0.000001;
		if(specialPrice<0)
			specialPrice-=0.000001;
		
			if(((long)((specialPrice)*100 ))*10!=(long)((specialPrice)*1000) )
				throw (new Exception("特价小数精度不能大于2位specialPrice="+specialPrice.ToString()));
		if(specialPrice>0)
			specialPrice-=0.000001;
		if(specialPrice<0)
			specialPrice+=0.000001;
	

	//try{Convert.ToDouble(wholesalePrice);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(wholesalePrice>0)
			wholesalePrice+=0.000001;
		if(wholesalePrice<0)
			wholesalePrice-=0.000001;
		
			if(((long)((wholesalePrice)*100 ))*10!=(long)((wholesalePrice)*1000) )
				throw (new Exception("批发价小数精度不能大于2位wholesalePrice="+wholesalePrice.ToString()));
		if(wholesalePrice>0)
			wholesalePrice-=0.000001;
		if(wholesalePrice<0)
			wholesalePrice+=0.000001;
	

	//try{Convert.ToDouble(memberPrice1);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(memberPrice1>0)
			memberPrice1+=0.000001;
		if(memberPrice1<0)
			memberPrice1-=0.000001;
		
			if(((long)((memberPrice1)*100 ))*10!=(long)((memberPrice1)*1000) )
				throw (new Exception("会员价1小数精度不能大于2位memberPrice1="+memberPrice1.ToString()));
		if(memberPrice1>0)
			memberPrice1-=0.000001;
		if(memberPrice1<0)
			memberPrice1+=0.000001;
	

	//try{Convert.ToDouble(memberPrice2);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(memberPrice2>0)
			memberPrice2+=0.000001;
		if(memberPrice2<0)
			memberPrice2-=0.000001;
		
			if(((long)((memberPrice2)*100 ))*10!=(long)((memberPrice2)*1000) )
				throw (new Exception("会员价2小数精度不能大于2位memberPrice2="+memberPrice2.ToString()));
		if(memberPrice2>0)
			memberPrice2-=0.000001;
		if(memberPrice2<0)
			memberPrice2+=0.000001;
	

	//try{Convert.ToDouble(memberPrice3);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(memberPrice3>0)
			memberPrice3+=0.000001;
		if(memberPrice3<0)
			memberPrice3-=0.000001;
		
			if(((long)((memberPrice3)*100 ))*10!=(long)((memberPrice3)*1000) )
				throw (new Exception("会员价3小数精度不能大于2位memberPrice3="+memberPrice3.ToString()));
		if(memberPrice3>0)
			memberPrice3-=0.000001;
		if(memberPrice3<0)
			memberPrice3+=0.000001;
	

	//try{Convert.ToInt32(packageFlag);}catch{ throw (new Exception("请输入正确的整数格式"));		}
		if(	packageFlag<consts.int_min+1)
			throw (new Exception("请输入是否包装"));

	
	len=packageCommodityID.Trim().Length;
	if(len>50)
		 throw (new Exception("包装商品号字符长度最长不能超过50,当前长度为"+len.ToString()));	
	

	//try{Convert.ToDouble(packageAmount);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(packageAmount>0)
			packageAmount+=0.000001;
		if(packageAmount<0)
			packageAmount-=0.000001;
		
			if(((long)((packageAmount)*100 ))*10!=(long)((packageAmount)*1000) )
				throw (new Exception("包装数小数精度不能大于2位packageAmount="+packageAmount.ToString()));
		if(packageAmount>0)
			packageAmount-=0.000001;
		if(packageAmount<0)
			packageAmount+=0.000001;
	

	
	len=commodityClass1.Trim().Length;
	if(len>20)
		 throw (new Exception("大类字符长度最长不能超过20,当前长度为"+len.ToString()));	
	

	
	len=commodityClass2.Trim().Length;
	if(len>20)
		 throw (new Exception("中类字符长度最长不能超过20,当前长度为"+len.ToString()));	
	

	
	len=commodityClass3.Trim().Length;
	if(len>20)
		 throw (new Exception("小类字符长度最长不能超过20,当前长度为"+len.ToString()));	
	

	
	len=pos1.Trim().Length;
	if(len>20)
		 throw (new Exception("货架位置字符长度最长不能超过20,当前长度为"+len.ToString()));	
	

	
	len=pos2.Trim().Length;
	if(len>20)
		 throw (new Exception("仓库位置字符长度最长不能超过20,当前长度为"+len.ToString()));	
	

	
	len=commodityBrank.Trim().Length;
	if(len>20)
		 throw (new Exception("品牌字符长度最长不能超过20,当前长度为"+len.ToString()));	
	

	
	len=commodityFactory.Trim().Length;
	if(len>20)
		 throw (new Exception("厂家(产地)字符长度最长不能超过20,当前长度为"+len.ToString()));	
	

	
	len=grade.Trim().Length;
	if(len>20)
		 throw (new Exception("等级字符长度最长不能超过20,当前长度为"+len.ToString()));	
	

	
	len=unit.Trim().Length;
	if(len>20)
		 throw (new Exception("单位字符长度最长不能超过20,当前长度为"+len.ToString()));	
	

	
	len=mark.Trim().Length;
	if(len>20)
		 throw (new Exception("货号字符长度最长不能超过20,当前长度为"+len.ToString()));	
	

	
	len=commodityType.Trim().Length;
	if(len>20)
		 throw (new Exception("型号字符长度最长不能超过20,当前长度为"+len.ToString()));	
	

	
	len=commodityKey.Trim().Length;
	if(len>50)
		 throw (new Exception("索引字符长度最长不能超过50,当前长度为"+len.ToString()));	
	

	
	len=commodityRemark.Trim().Length;
	if(len>512)
		 throw (new Exception("备注字符长度最长不能超过512,当前长度为"+len.ToString()));	
	

	
	len=addUserID.Trim().Length;
	if(len>20)
		 throw (new Exception("添加人字符长度最长不能超过20,当前长度为"+len.ToString()));	
	

	//try{Convert.ToDateTime(addTime);}catch{ throw (new Exception("请输入正确的长整数格式"));		}

	
	len=modifyUserID.Trim().Length;
	if(len>20)
		 throw (new Exception("修改人字符长度最长不能超过20,当前长度为"+len.ToString()));	
	

	//try{Convert.ToDateTime(modifyTime);}catch{ throw (new Exception("请输入正确的长整数格式"));		}

//unique="yes" 唯一性验证
		ICriterion crit=Restrictions.Eq("seqID", seqID);
		crit=Restrictions.Or(crit,Restrictions.Eq("commodityID", commodityID));
		crit=Restrictions.Or(crit,Restrictions.Eq("commodityName", commodityName));
  		IList list=dao.List(dao.DC.Add(crit));
		if(list.Count==1)
			return;
		if(list.Count==0)
			throw (new Exception("该记录已经被删除"));	
		else
			throw (new Exception("改纪录出现重名!"));
    }
    public void add()
    {
        try
        {
            checkAdd();
         	dao.Add(__commodity);
        }
        catch(Exception ex)
        {
            throw (new Exception(ex.Message));
        }
    }
   
    public void delByseqID()
    {
    
        try
        {
          dao.Delete(__commodity);
        }
        catch(Exception ex)
        {
            throw (new Exception(ex.Message));
        }
    }

    public  void update()
    {
        try
        {
            checkUpdate();
            dao.Update(__commodity);
        }
        catch (Exception ex)
        {
            throw (new Exception(ex.Message));
        }
    }
   
    public void ExecDataUpdate(int rowNo)
    {
		if(m_updateRow==null)
			return;
		int ii=0;
m_updateRow(rowNo,ii++,				(				  string.Format("{0}",seqID)				  ));	
m_updateRow(rowNo,ii++,commodityID);	
m_updateRow(rowNo,ii++,commodityName);	
m_updateRow(rowNo,ii++,commoditySpec);	
m_updateRow(rowNo,ii++,/***/(						string.Format("{0:F2}",retailPrice)/***/)
);	
m_updateRow(rowNo,ii++,packageCommodityID);	
m_updateRow(rowNo,ii++,/***/(					Convert.ToDouble(string.Format("{0:F2}",packageAmount))<(consts.double_min+1)?"":string.Format("{0:F2}",/***/packageAmount/***/)/***/)
);	
m_updateRow(rowNo,ii++,commodityClass1);	
m_updateRow(rowNo,ii++,commodityClass2);	
m_updateRow(rowNo,ii++,commodityClass3);	
m_updateRow(rowNo,ii++,pos1);	
m_updateRow(rowNo,ii++,pos2);	
m_updateRow(rowNo,ii++,commodityKey);	

    }
    public void ExecHeadInsert()
    {
		if(m_insertHead!=null)
        {
			int ii=0;
			m_insertHead(ii++,40,"编号");
			m_insertHead(ii++,90,"商品条形码");
			m_insertHead(ii++,180,"商品名称");
			m_insertHead(ii++,100,"规格");
			m_insertHead(ii++,65,"零售价");
			m_insertHead(ii++,90,"包装商品号");
			m_insertHead(ii++,60,"包装数");
			m_insertHead(ii++,100,"大类");
			m_insertHead(ii++,100,"中类");
			m_insertHead(ii++,100,"小类");
			m_insertHead(ii++,100,"货架位置");
			m_insertHead(ii++,100,"仓库位置");
			m_insertHead(ii++,80,"索引");
		}		
    }
    public void ExecDataInsert()
	{
		if(m_insertRow==null)
			return;
		int ii=0;
     	m_insertRow(0,ii++,				(				  string.Format("{0}",seqID)				  ));
     	m_insertRow(0,ii++,commodityID);
     	m_insertRow(0,ii++,commodityName);
     	m_insertRow(0,ii++,commoditySpec);
     	m_insertRow(0,ii++,/***/(						string.Format("{0:F2}",retailPrice)/***/)
);
     	m_insertRow(0,ii++,packageCommodityID);
     	m_insertRow(0,ii++,/***/(					Convert.ToDouble(string.Format("{0:F2}",packageAmount))<(consts.double_min+1)?"":string.Format("{0:F2}",/***/packageAmount/***/)/***/)
);
     	m_insertRow(0,ii++,commodityClass1);
     	m_insertRow(0,ii++,commodityClass2);
     	m_insertRow(0,ii++,commodityClass3);
     	m_insertRow(0,ii++,pos1);
     	m_insertRow(0,ii++,pos2);
     	m_insertRow(0,ii++,commodityKey);
    }
    public void ExecDataInsertByQuery(DetachedCriteria dc)
    {
      
         IList list=dao.List(dc); 
        
        if(m_insertHead!=null)
        {
			int ii=0;
			m_insertHead(ii++,40,"编号");
			m_insertHead(ii++,90,"商品条形码");
			m_insertHead(ii++,180,"商品名称");
			m_insertHead(ii++,100,"规格");
			m_insertHead(ii++,65,"零售价");
			m_insertHead(ii++,90,"包装商品号");
			m_insertHead(ii++,60,"包装数");
			m_insertHead(ii++,100,"大类");
			m_insertHead(ii++,100,"中类");
			m_insertHead(ii++,100,"小类");
			m_insertHead(ii++,100,"货架位置");
			m_insertHead(ii++,100,"仓库位置");
			m_insertHead(ii++,80,"索引");
		}		
		
      if(m_insertRow!=null)
      {
        int j=0;
        foreach(Commodity obj in list)			
        {
		  int ii=0;
	     
m_insertRow(j,ii++,				(				  string.Format("{0}",obj.seqID)
				  )
);
m_insertRow(j,ii++,obj.commodityID.ToString());
m_insertRow(j,ii++,obj.commodityName.ToString());
m_insertRow(j,ii++,obj.commoditySpec.ToString());
m_insertRow(j,ii++,(					string.Format("{0:F2}",obj.retailPrice)
					)
);
m_insertRow(j,ii++,obj.packageCommodityID.ToString());
m_insertRow(j,ii++,(
					Convert.ToDouble(string.Format("{0:F2}",obj.packageAmount))<(consts.double_min+1)?"":string.Format("{0:F2}",obj.packageAmount)
)
);
m_insertRow(j,ii++,obj.commodityClass1.ToString());
m_insertRow(j,ii++,obj.commodityClass2.ToString());
m_insertRow(j,ii++,obj.commodityClass3.ToString());
m_insertRow(j,ii++,obj.pos1.ToString());
m_insertRow(j,ii++,obj.pos2.ToString());
m_insertRow(j,ii++,obj.commodityKey.ToString());
		j++;
        }
        

	
       }
    }

    
    public IList List(DetachedCriteria dc)
    {
        try
        {
           
            return dao.List(dc);
        }
        catch (Exception ex)
        {
            throw (new Exception(ex.Message));
        }
    }
    
    public bool Init(DetachedCriteria dc)
    {
    
    		Commodity obj=dao.Get(dc);
    		if(obj==null)
    			return false;
    		else
    		{
    			__commodity=obj;
            	return true;
            }
        
    }
    public static t_commodity Get(DetachedCriteria dc)
    {
    	
    	Commodity obj=((CommodityDao)SpringContext.Context.GetObject("CommodityDao"))
	 	.Get(dc);
	 	if(obj==null)
	 		return null;
	 	else
	 		return new t_commodity( obj );
        
    }
	 public static t_commodity GetBySeqID(long val)
	 {
	 	Commodity obj=((CommodityDao)SpringContext.Context.GetObject("CommodityDao"))
	 	.GetBySeqID(val);
	 	if(obj==null)
	 		return null;
	 	else
	 		return new t_commodity( obj );
	 	
	 	
	 }
	 public  bool InitBySeqID(long val)
	 {
	 	

	 	Commodity obj=dao.GetBySeqID(val) ;
	 	if(obj==null)
	 		return false;
	 	else
	 	{
	 		__commodity=obj;
	 		return true;
	 	}
	 	
	 	
	 }
	 public static t_commodity GetByCommodityID(String val)
	 {
	 	Commodity obj=((CommodityDao)SpringContext.Context.GetObject("CommodityDao"))
	 	.GetByCommodityID(val);
	 	if(obj==null)
	 		return null;
	 	else
	 		return new t_commodity( obj );
	 	
	 	
	 }
	 public  bool InitByCommodityID(String val)
	 {
	 	

	 	Commodity obj=dao.GetByCommodityID(val) ;
	 	if(obj==null)
	 		return false;
	 	else
	 	{
	 		__commodity=obj;
	 		return true;
	 	}
	 	
	 	
	 }
	 public static t_commodity GetByCommodityName(String val)
	 {
	 	Commodity obj=((CommodityDao)SpringContext.Context.GetObject("CommodityDao"))
	 	.GetByCommodityName(val);
	 	if(obj==null)
	 		return null;
	 	else
	 		return new t_commodity( obj );
	 	
	 	
	 }
	 public  bool InitByCommodityName(String val)
	 {
	 	

	 	Commodity obj=dao.GetByCommodityName(val) ;
	 	if(obj==null)
	 		return false;
	 	else
	 	{
	 		__commodity=obj;
	 		return true;
	 	}
	 	
	 	
	 }
    
       public bool showInForm(Control.ControlCollection Controls)
    {
        try
        {
             
		if(Controls["seqID"]!=null)
		{
			Controls["seqID"].Text=				(				  string.Format("{0}",seqID)				  );
		}
		if(Controls["commodityID"]!=null)
		{
			Controls["commodityID"].Text=commodityID;
		}
		if(Controls["commodityName"]!=null)
		{
			Controls["commodityName"].Text=commodityName;
		}
		if(Controls["commoditySpec"]!=null)
		{
			Controls["commoditySpec"].Text=commoditySpec;
		}
		if(Controls["commodityState"]!=null)
		{
			Controls["commodityState"].Text=	t_commodity.enum_commodityState[commodityState.ToString()].ToString()
;
		}
		if(Controls["storageState"]!=null)
		{
			Controls["storageState"].Text=	t_commodity.enum_storageState[storageState.ToString()].ToString()
;
		}
		if(Controls["retailPrice"]!=null)
		{
			Controls["retailPrice"].Text=/***/(						string.Format("{0:F2}",retailPrice)/***/)
;
		}
		if(Controls["specialOffer"]!=null)
		{
			Controls["specialOffer"].Text=	t_commodity.enum_specialOffer[specialOffer.ToString()].ToString()
;
		}
		if(Controls["specialPrice"]!=null)
		{
			Controls["specialPrice"].Text=/***/(					Convert.ToDouble(string.Format("{0:F2}",specialPrice))<(consts.double_min+1)?"":string.Format("{0:F2}",/***/specialPrice/***/)/***/)
;
		}
		if(Controls["wholesalePrice"]!=null)
		{
			Controls["wholesalePrice"].Text=/***/(					Convert.ToDouble(string.Format("{0:F2}",wholesalePrice))<(consts.double_min+1)?"":string.Format("{0:F2}",/***/wholesalePrice/***/)/***/)
;
		}
		if(Controls["memberPrice1"]!=null)
		{
			Controls["memberPrice1"].Text=/***/(					Convert.ToDouble(string.Format("{0:F2}",memberPrice1))<(consts.double_min+1)?"":string.Format("{0:F2}",/***/memberPrice1/***/)/***/)
;
		}
		if(Controls["memberPrice2"]!=null)
		{
			Controls["memberPrice2"].Text=/***/(					Convert.ToDouble(string.Format("{0:F2}",memberPrice2))<(consts.double_min+1)?"":string.Format("{0:F2}",/***/memberPrice2/***/)/***/)
;
		}
		if(Controls["memberPrice3"]!=null)
		{
			Controls["memberPrice3"].Text=/***/(					Convert.ToDouble(string.Format("{0:F2}",memberPrice3))<(consts.double_min+1)?"":string.Format("{0:F2}",/***/memberPrice3/***/)/***/)
;
		}
		if(Controls["packageFlag"]!=null)
		{
			Controls["packageFlag"].Text=	t_commodity.enum_packageFlag[packageFlag.ToString()].ToString()
;
		}
		if(Controls["packageCommodityID"]!=null)
		{
			Controls["packageCommodityID"].Text=packageCommodityID;
		}
		if(Controls["packageAmount"]!=null)
		{
			Controls["packageAmount"].Text=/***/(					Convert.ToDouble(string.Format("{0:F2}",packageAmount))<(consts.double_min+1)?"":string.Format("{0:F2}",/***/packageAmount/***/)/***/)
;
		}
		if(Controls["commodityClass1"]!=null)
		{
			Controls["commodityClass1"].Text=commodityClass1;
		}
		if(Controls["commodityClass2"]!=null)
		{
			Controls["commodityClass2"].Text=commodityClass2;
		}
		if(Controls["commodityClass3"]!=null)
		{
			Controls["commodityClass3"].Text=commodityClass3;
		}
		if(Controls["pos1"]!=null)
		{
			Controls["pos1"].Text=pos1;
		}
		if(Controls["pos2"]!=null)
		{
			Controls["pos2"].Text=pos2;
		}
		if(Controls["commodityBrank"]!=null)
		{
			Controls["commodityBrank"].Text=commodityBrank;
		}
		if(Controls["commodityFactory"]!=null)
		{
			Controls["commodityFactory"].Text=commodityFactory;
		}
		if(Controls["grade"]!=null)
		{
			Controls["grade"].Text=grade;
		}
		if(Controls["unit"]!=null)
		{
			Controls["unit"].Text=unit;
		}
		if(Controls["mark"]!=null)
		{
			Controls["mark"].Text=mark;
		}
		if(Controls["commodityType"]!=null)
		{
			Controls["commodityType"].Text=commodityType;
		}
		if(Controls["commodityKey"]!=null)
		{
			Controls["commodityKey"].Text=commodityKey;
		}
		if(Controls["commodityRemark"]!=null)
		{
			Controls["commodityRemark"].Text=commodityRemark;
		}
		if(Controls["addUserID"]!=null)
		{
			Controls["addUserID"].Text=addUserID;
		}
		if(Controls["addTime"]!=null)
		{
			Controls["addTime"].Text=			addTime.ToString().CompareTo("1001-1-1")<0?"":string.Format("{0:g}",addTime);
		}
		if(Controls["modifyUserID"]!=null)
		{
			Controls["modifyUserID"].Text=modifyUserID;
		}
		if(Controls["modifyTime"]!=null)
		{
			Controls["modifyTime"].Text=			modifyTime.ToString().CompareTo("1001-1-1")<0?"":string.Format("{0:g}",modifyTime);
		}
			return true;
        }
        catch (Exception ex)
        {
            throw (new Exception(ex.Message));
            
        }
    }
    public  t_commodity Init(Commodity item)
    {
        __commodity=item;
        return this;
    }

    
     public bool initByForm(Control.ControlCollection Controls)
    {
        try
        {
             
		if(Controls["seqID"]!=null)
		{
			
			if(Controls["seqID"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["seqID"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{seqID=(v==""?consts.long_min:Convert.ToInt32(v));}
				catch
				{
					 Controls["seqID"].Focus();
					throw  (new Exception("编号格式不正确！！"));
				}
				
			}
			else
			{
				try{seqID=(Controls["seqID"].Text==""?consts.long_min:Convert.ToInt32(Controls["seqID"].Text));}
				catch
				{
					 Controls["seqID"].Focus();
					throw  (new Exception("编号格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["commodityID"]!=null)
		{
			
			if(Controls["commodityID"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["commodityID"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{commodityID=v;}
				catch
				{
					 Controls["commodityID"].Focus();
					throw  (new Exception("商品条形码格式不正确！！"));
				}
				
			}
			else
			{
				try{commodityID=Controls["commodityID"].Text;}
				catch
				{
					 Controls["commodityID"].Focus();
					throw  (new Exception("商品条形码格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["commodityName"]!=null)
		{
			
			if(Controls["commodityName"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["commodityName"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{commodityName=v;}
				catch
				{
					 Controls["commodityName"].Focus();
					throw  (new Exception("商品名称格式不正确！！"));
				}
				
			}
			else
			{
				try{commodityName=Controls["commodityName"].Text;}
				catch
				{
					 Controls["commodityName"].Focus();
					throw  (new Exception("商品名称格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["commoditySpec"]!=null)
		{
			
			if(Controls["commoditySpec"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["commoditySpec"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{commoditySpec=v;}
				catch
				{
					 Controls["commoditySpec"].Focus();
					throw  (new Exception("规格格式不正确！！"));
				}
				
			}
			else
			{
				try{commoditySpec=Controls["commoditySpec"].Text;}
				catch
				{
					 Controls["commoditySpec"].Focus();
					throw  (new Exception("规格格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["commodityState"]!=null)
		{
			
			if(Controls["commodityState"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["commodityState"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{commodityState=(v==""?consts.int_min:Convert.ToInt32(v));}
				catch
				{
					 Controls["commodityState"].Focus();
					throw  (new Exception("商品状态格式不正确！！"));
				}
				
			}
			else
			{
				try{commodityState=(Controls["commodityState"].Text==""?consts.int_min:Convert.ToInt32(Controls["commodityState"].Text));}
				catch
				{
					 Controls["commodityState"].Focus();
					throw  (new Exception("商品状态格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["storageState"]!=null)
		{
			
			if(Controls["storageState"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["storageState"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{storageState=(v==""?consts.int_min:Convert.ToInt32(v));}
				catch
				{
					 Controls["storageState"].Focus();
					throw  (new Exception("库存状态格式不正确！！"));
				}
				
			}
			else
			{
				try{storageState=(Controls["storageState"].Text==""?consts.int_min:Convert.ToInt32(Controls["storageState"].Text));}
				catch
				{
					 Controls["storageState"].Focus();
					throw  (new Exception("库存状态格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["retailPrice"]!=null)
		{
			
			if(Controls["retailPrice"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["retailPrice"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{retailPrice=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["retailPrice"].Focus();
					throw  (new Exception("零售价格式不正确！！"));
				}
				
			}
			else
			{
				try{retailPrice=(Controls["retailPrice"].Text==""?consts.double_min:Convert.ToDouble(Controls["retailPrice"].Text));}
				catch
				{
					 Controls["retailPrice"].Focus();
					throw  (new Exception("零售价格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["specialOffer"]!=null)
		{
			
			if(Controls["specialOffer"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["specialOffer"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{specialOffer=(v==""?consts.int_min:Convert.ToInt32(v));}
				catch
				{
					 Controls["specialOffer"].Focus();
					throw  (new Exception("是否特价格式不正确！！"));
				}
				
			}
			else
			{
				try{specialOffer=(Controls["specialOffer"].Text==""?consts.int_min:Convert.ToInt32(Controls["specialOffer"].Text));}
				catch
				{
					 Controls["specialOffer"].Focus();
					throw  (new Exception("是否特价格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["specialPrice"]!=null)
		{
			
			if(Controls["specialPrice"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["specialPrice"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{specialPrice=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["specialPrice"].Focus();
					throw  (new Exception("特价格式不正确！！"));
				}
				
			}
			else
			{
				try{specialPrice=(Controls["specialPrice"].Text==""?consts.double_min:Convert.ToDouble(Controls["specialPrice"].Text));}
				catch
				{
					 Controls["specialPrice"].Focus();
					throw  (new Exception("特价格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["wholesalePrice"]!=null)
		{
			
			if(Controls["wholesalePrice"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["wholesalePrice"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{wholesalePrice=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["wholesalePrice"].Focus();
					throw  (new Exception("批发价格式不正确！！"));
				}
				
			}
			else
			{
				try{wholesalePrice=(Controls["wholesalePrice"].Text==""?consts.double_min:Convert.ToDouble(Controls["wholesalePrice"].Text));}
				catch
				{
					 Controls["wholesalePrice"].Focus();
					throw  (new Exception("批发价格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["memberPrice1"]!=null)
		{
			
			if(Controls["memberPrice1"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["memberPrice1"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{memberPrice1=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["memberPrice1"].Focus();
					throw  (new Exception("会员价1格式不正确！！"));
				}
				
			}
			else
			{
				try{memberPrice1=(Controls["memberPrice1"].Text==""?consts.double_min:Convert.ToDouble(Controls["memberPrice1"].Text));}
				catch
				{
					 Controls["memberPrice1"].Focus();
					throw  (new Exception("会员价1格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["memberPrice2"]!=null)
		{
			
			if(Controls["memberPrice2"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["memberPrice2"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{memberPrice2=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["memberPrice2"].Focus();
					throw  (new Exception("会员价2格式不正确！！"));
				}
				
			}
			else
			{
				try{memberPrice2=(Controls["memberPrice2"].Text==""?consts.double_min:Convert.ToDouble(Controls["memberPrice2"].Text));}
				catch
				{
					 Controls["memberPrice2"].Focus();
					throw  (new Exception("会员价2格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["memberPrice3"]!=null)
		{
			
			if(Controls["memberPrice3"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["memberPrice3"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{memberPrice3=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["memberPrice3"].Focus();
					throw  (new Exception("会员价3格式不正确！！"));
				}
				
			}
			else
			{
				try{memberPrice3=(Controls["memberPrice3"].Text==""?consts.double_min:Convert.ToDouble(Controls["memberPrice3"].Text));}
				catch
				{
					 Controls["memberPrice3"].Focus();
					throw  (new Exception("会员价3格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["packageFlag"]!=null)
		{
			
			if(Controls["packageFlag"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["packageFlag"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{packageFlag=(v==""?consts.int_min:Convert.ToInt32(v));}
				catch
				{
					 Controls["packageFlag"].Focus();
					throw  (new Exception("是否包装格式不正确！！"));
				}
				
			}
			else
			{
				try{packageFlag=(Controls["packageFlag"].Text==""?consts.int_min:Convert.ToInt32(Controls["packageFlag"].Text));}
				catch
				{
					 Controls["packageFlag"].Focus();
					throw  (new Exception("是否包装格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["packageCommodityID"]!=null)
		{
			
			if(Controls["packageCommodityID"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["packageCommodityID"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{packageCommodityID=v;}
				catch
				{
					 Controls["packageCommodityID"].Focus();
					throw  (new Exception("包装商品号格式不正确！！"));
				}
				
			}
			else
			{
				try{packageCommodityID=Controls["packageCommodityID"].Text;}
				catch
				{
					 Controls["packageCommodityID"].Focus();
					throw  (new Exception("包装商品号格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["packageAmount"]!=null)
		{
			
			if(Controls["packageAmount"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["packageAmount"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{packageAmount=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["packageAmount"].Focus();
					throw  (new Exception("包装数格式不正确！！"));
				}
				
			}
			else
			{
				try{packageAmount=(Controls["packageAmount"].Text==""?consts.double_min:Convert.ToDouble(Controls["packageAmount"].Text));}
				catch
				{
					 Controls["packageAmount"].Focus();
					throw  (new Exception("包装数格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["commodityClass1"]!=null)
		{
			
			if(Controls["commodityClass1"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["commodityClass1"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{commodityClass1=v;}
				catch
				{
					 Controls["commodityClass1"].Focus();
					throw  (new Exception("大类格式不正确！！"));
				}
				
			}
			else
			{
				try{commodityClass1=Controls["commodityClass1"].Text;}
				catch
				{
					 Controls["commodityClass1"].Focus();
					throw  (new Exception("大类格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["commodityClass2"]!=null)
		{
			
			if(Controls["commodityClass2"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["commodityClass2"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{commodityClass2=v;}
				catch
				{
					 Controls["commodityClass2"].Focus();
					throw  (new Exception("中类格式不正确！！"));
				}
				
			}
			else
			{
				try{commodityClass2=Controls["commodityClass2"].Text;}
				catch
				{
					 Controls["commodityClass2"].Focus();
					throw  (new Exception("中类格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["commodityClass3"]!=null)
		{
			
			if(Controls["commodityClass3"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["commodityClass3"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{commodityClass3=v;}
				catch
				{
					 Controls["commodityClass3"].Focus();
					throw  (new Exception("小类格式不正确！！"));
				}
				
			}
			else
			{
				try{commodityClass3=Controls["commodityClass3"].Text;}
				catch
				{
					 Controls["commodityClass3"].Focus();
					throw  (new Exception("小类格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["pos1"]!=null)
		{
			
			if(Controls["pos1"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["pos1"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{pos1=v;}
				catch
				{
					 Controls["pos1"].Focus();
					throw  (new Exception("货架位置格式不正确！！"));
				}
				
			}
			else
			{
				try{pos1=Controls["pos1"].Text;}
				catch
				{
					 Controls["pos1"].Focus();
					throw  (new Exception("货架位置格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["pos2"]!=null)
		{
			
			if(Controls["pos2"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["pos2"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{pos2=v;}
				catch
				{
					 Controls["pos2"].Focus();
					throw  (new Exception("仓库位置格式不正确！！"));
				}
				
			}
			else
			{
				try{pos2=Controls["pos2"].Text;}
				catch
				{
					 Controls["pos2"].Focus();
					throw  (new Exception("仓库位置格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["commodityBrank"]!=null)
		{
			
			if(Controls["commodityBrank"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["commodityBrank"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{commodityBrank=v;}
				catch
				{
					 Controls["commodityBrank"].Focus();
					throw  (new Exception("品牌格式不正确！！"));
				}
				
			}
			else
			{
				try{commodityBrank=Controls["commodityBrank"].Text;}
				catch
				{
					 Controls["commodityBrank"].Focus();
					throw  (new Exception("品牌格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["commodityFactory"]!=null)
		{
			
			if(Controls["commodityFactory"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["commodityFactory"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{commodityFactory=v;}
				catch
				{
					 Controls["commodityFactory"].Focus();
					throw  (new Exception("厂家(产地)格式不正确！！"));
				}
				
			}
			else
			{
				try{commodityFactory=Controls["commodityFactory"].Text;}
				catch
				{
					 Controls["commodityFactory"].Focus();
					throw  (new Exception("厂家(产地)格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["grade"]!=null)
		{
			
			if(Controls["grade"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["grade"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{grade=v;}
				catch
				{
					 Controls["grade"].Focus();
					throw  (new Exception("等级格式不正确！！"));
				}
				
			}
			else
			{
				try{grade=Controls["grade"].Text;}
				catch
				{
					 Controls["grade"].Focus();
					throw  (new Exception("等级格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["unit"]!=null)
		{
			
			if(Controls["unit"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["unit"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{unit=v;}
				catch
				{
					 Controls["unit"].Focus();
					throw  (new Exception("单位格式不正确！！"));
				}
				
			}
			else
			{
				try{unit=Controls["unit"].Text;}
				catch
				{
					 Controls["unit"].Focus();
					throw  (new Exception("单位格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["mark"]!=null)
		{
			
			if(Controls["mark"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["mark"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{mark=v;}
				catch
				{
					 Controls["mark"].Focus();
					throw  (new Exception("货号格式不正确！！"));
				}
				
			}
			else
			{
				try{mark=Controls["mark"].Text;}
				catch
				{
					 Controls["mark"].Focus();
					throw  (new Exception("货号格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["commodityType"]!=null)
		{
			
			if(Controls["commodityType"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["commodityType"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{commodityType=v;}
				catch
				{
					 Controls["commodityType"].Focus();
					throw  (new Exception("型号格式不正确！！"));
				}
				
			}
			else
			{
				try{commodityType=Controls["commodityType"].Text;}
				catch
				{
					 Controls["commodityType"].Focus();
					throw  (new Exception("型号格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["commodityKey"]!=null)
		{
			
			if(Controls["commodityKey"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["commodityKey"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{commodityKey=v;}
				catch
				{
					 Controls["commodityKey"].Focus();
					throw  (new Exception("索引格式不正确！！"));
				}
				
			}
			else
			{
				try{commodityKey=Controls["commodityKey"].Text;}
				catch
				{
					 Controls["commodityKey"].Focus();
					throw  (new Exception("索引格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["commodityRemark"]!=null)
		{
			
			if(Controls["commodityRemark"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["commodityRemark"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{commodityRemark=v;}
				catch
				{
					 Controls["commodityRemark"].Focus();
					throw  (new Exception("备注格式不正确！！"));
				}
				
			}
			else
			{
				try{commodityRemark=Controls["commodityRemark"].Text;}
				catch
				{
					 Controls["commodityRemark"].Focus();
					throw  (new Exception("备注格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["addUserID"]!=null)
		{
			
			if(Controls["addUserID"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["addUserID"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{addUserID=v;}
				catch
				{
					 Controls["addUserID"].Focus();
					throw  (new Exception("添加人格式不正确！！"));
				}
				
			}
			else
			{
				try{addUserID=Controls["addUserID"].Text;}
				catch
				{
					 Controls["addUserID"].Focus();
					throw  (new Exception("添加人格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["addTime"]!=null)
		{
			
			if(Controls["addTime"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["addTime"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{addTime=(v==""?new DateTime(1000,1,1):Convert.ToDateTime(v));}
				catch
				{
					 Controls["addTime"].Focus();
					throw  (new Exception("添加时间格式不正确！！"));
				}
				
			}
			else
			{
				try{addTime=(Controls["addTime"].Text==""?new DateTime(1000,1,1):Convert.ToDateTime(Controls["addTime"].Text));}
				catch
				{
					 Controls["addTime"].Focus();
					throw  (new Exception("添加时间格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["modifyUserID"]!=null)
		{
			
			if(Controls["modifyUserID"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["modifyUserID"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{modifyUserID=v;}
				catch
				{
					 Controls["modifyUserID"].Focus();
					throw  (new Exception("修改人格式不正确！！"));
				}
				
			}
			else
			{
				try{modifyUserID=Controls["modifyUserID"].Text;}
				catch
				{
					 Controls["modifyUserID"].Focus();
					throw  (new Exception("修改人格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["modifyTime"]!=null)
		{
			
			if(Controls["modifyTime"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["modifyTime"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{modifyTime=(v==""?new DateTime(1000,1,1):Convert.ToDateTime(v));}
				catch
				{
					 Controls["modifyTime"].Focus();
					throw  (new Exception("修改时间格式不正确！！"));
				}
				
			}
			else
			{
				try{modifyTime=(Controls["modifyTime"].Text==""?new DateTime(1000,1,1):Convert.ToDateTime(Controls["modifyTime"].Text));}
				catch
				{
					 Controls["modifyTime"].Focus();
					throw  (new Exception("修改时间格式不正确！！"));
				}
				
			}
				
				
		}
			return true;
        }
        catch (Exception ex)
        {
            throw (new Exception(ex.Message));
            
        }
    }
    

}

}
